package com.jwthhealth_pub.old.constitution.view;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ScrollView;
import android.widget.Toast;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.common.view.TitleLayout;
import com.jwthhealth_pub.old.constitution.view.adapter.ConstitutionAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/12/14.
 */

public class ConstitutionActivity extends Activity {

    public static final int TOAS = 0;
    public static final String UNCOMPLETETYPE = "uncompletetype";


    @BindView(R.id.title_layout)
    TitleLayout titleLayout;
    @BindView(R.id.rv_constitution)
    RecyclerView rvConstitution;
    @BindView(R.id.scrollView)
    ScrollView scrollView;

    public Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == TOAS) {
                Toast.makeText(ConstitutionActivity.this, R.string.constitution_one_hint, Toast.LENGTH_SHORT).show();
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_constitution);
        ButterKnife.bind(this);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }

        rvConstitution.setLayoutManager(new GridLayoutManager(this, 3));
        rvConstitution.setAdapter(new ConstitutionAdapter(this));

        initListener();
    }

    private void initListener() {
        titleLayout.setOnTitleLayoutListener(new TitleLayout.TitleLayoutListener() {
            @Override
            public void leftclick() {
                finish();
            }

            @Override
            public void leftTextClick() {

            }

            @Override
            public void rightclick() {

            }

            @Override
            public void rightTextClick() {

            }
        });
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        scrollView.fullScroll(ScrollView.FOCUS_UP);
    }
}
